//
//  HSHttpBaseRequest.h
//  AFNetworking
//
//  Created by huang on 2018/8/16.
//

#import <Foundation/Foundation.h>

typedef void(^HttpSuccessBlock)(id responseObject);
typedef void(^HttpFailureBlock)(NSError *error);

@interface HSHttpBaseRequest : NSObject

+ (instancetype)shareInstance;

/**
 *  get请求
 *
 *  @param path    路径
 *  @param params  参数
 *  @param isCache  是否有缓存
 *  @param success 成功回调
 *  @param failure 失败回调
 */
- (void)getWithPath:(NSString *)path params:(NSDictionary *)params isCache:(BOOL)isCache success:(HttpSuccessBlock)success failure:(HttpFailureBlock)failure;
- (void)getWithPath:(NSString *)path params:(NSDictionary *)params success:(HttpSuccessBlock)success failure:(HttpFailureBlock)failure;

/**
 *  post请求
 *
 *  @param path    路径
 *  @param params  参数
 *  @param isCache  是否有缓存
 *  @param success 成功回调
 *  @param failure 失败回调
 */
- (void)postWithPath:(NSString *)path params:(NSDictionary *)params isCache:(BOOL)isCache success:(HttpSuccessBlock)success failure:(HttpFailureBlock)failure;
- (void)postWithPath:(NSString *)path params:(NSDictionary *)params success:(HttpSuccessBlock)success failure:(HttpFailureBlock)failure;


/**
 *  子类继承时可重写这两个方法
 */
- (NSDictionary *)correntParams:(NSDictionary *)params;
- (void)analyticalData:(NSDictionary *)responseObject success:(HttpSuccessBlock)success failure:(HttpFailureBlock)failure;


/**
 获取数据缓存的key

 @param baseUrl url
 @param params 参数
 @return 将传递进来的参数拼接成url
 */
+ (NSString *)cacheKeyWithUrl:(NSString *)baseUrl params:(NSMutableDictionary *)params;

@end
